﻿//--------------------------------------------------------------------------
// 
//  Copyright (c) Chili Software.  All rights reserved. 
// 
//  File: OPath.cs
//
//  Description: Parses OPath to an ObjectExpression.
// 
//--------------------------------------------------------------------------

using System;
using System.Reflection;
using System.Collections.Generic;
using Chili.Opf3.Query.OPathParser;

namespace Chili.Opf3.Query
{
	/// <summary>
	/// This class parses OPath expressions.
	/// </summary>
	/// <remarks>
	/// The framework implements some kind of OPath language (the name is taken from the 
	/// no longer developed Microsoft(R) ObjectSpaces(TM) framework). OPath would be 
	/// a kind of query language that is storage independent. This class parses and 
	/// converts the OPath expressions to an <see cref="Opf3.Query.ObjectExpression">ObjectExpression</see>
	/// that can the be compiled and executed on the storage.
	/// </remarks>
	public sealed class OPath
	{
		/// <summary>
		/// Creates a new instance of the <see cref="OPath">OPath Class</see>.
		/// </summary>
		private OPath()
		{
		}

		/// <summary>
		/// Parses the <see cref="Opf3.Query.ObjectQuery{T}">ObjectQuery</see>.
		/// </summary>
		/// <param name="query"><see cref="Opf3.Query.ObjectQuery{T}">ObjectQuery</see> that is parsed.</param>
		/// <exception cref="ArgumentNullException">Query is null.</exception>
		public static ObjectExpression Parse<T>(ObjectQuery<T> query)
		{
			if (query == null)
				throw new ArgumentNullException("query");

			// Create a new parser and parse the query.
			OPathParser<T> parser = new OPathParser<T>();
			return parser.Parse(query);
		}
	}
}
